﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using POSSystem.DAL;
using System.Collections.Specialized;
using System.Data.SqlClient;
using System.Data;

namespace POSSystem.BLL
{
    public class Sequence:_Sequence
    {
        public String GetNewSeqValue(String seqKey)
        {
            ListDictionary parameters = new ListDictionary();
			
			parameters.Add( new SqlParameter("@seqKey", SqlDbType.NVarChar, 50), seqKey);
			parameters.Add( new SqlParameter("@seqDate", SqlDbType.DateTime, 0), DateTime.UtcNow.AddHours(SystemVariables.SysVars.TimeZone));
            LoadFromSql("GetNewSeqValue", parameters);

			return SeqValue.ToString().PadLeft(4, '0');
        }

        public String GetNewID(String seqKey)
        {
            return DateTime.UtcNow.AddHours(SystemVariables.SysVars.TimeZone).ToString("yyMMdd") + GetNewSeqValue(seqKey);
        }
    }
}
